# 定义和使用线程：使用_thread模块
import _thread
import time


# Define a function for the thread
def sell_ticket(thread_name):
    count = 0
    while count < 5:
        time.sleep(2)
        count += 1
        print("%s: %s" % (thread_name, '卖出了一张票'))


# Create two threads as follows
try:
    # 补充 _thread模块 启动新线程的代码
    # print('补充启动新线程的代码')
    # 定义元组时，如果元组只有1个元素，后面需要使用,
    _thread.start_new_thread(sell_ticket, ('窗口一',))
    _thread.start_new_thread(sell_ticket, ('窗口二',))

except:
    print("Error: unable to start thread")

while 1:
    pass
